package tech.aistar.corejava.day06.day06work.Test01;

/**
 * 父类
 * Created by 豆梦寒 on 2019/7/22.
 */
public class Account {
    private int accNo;//账号
    private String accName;//名字
    private String accPassword;//密码
    private boolean accType;//账户类型
    private double accbalance;//账户余额
    private double turnover;//交易额

    public Account() {
    }

    public Account(int accNo, String accName, String accPassword, boolean accType, double accbalance, double turnover) {
        this.accNo = accNo;
        this.accName = accName;
        this.accPassword = accPassword;
        this.accType = accType;
        this.accbalance = accbalance;
        this.turnover = turnover;
    }

    public int getAccNo() {
        return accNo;
    }

    public void setAccNo(int accNo) {
        this.accNo = accNo;
    }

    public String getAccName() {
        return accName;
    }

    public void setAccName(String accName) {
        this.accName = accName;
    }

    public String getAccPassword() {
        return accPassword;
    }

    public void setAccPassword(String accPassword) {
        this.accPassword = accPassword;
    }

    public boolean getAccType() {
        return accType;
    }

    public void setAccType(boolean accType) {
        this.accType = accType;
    }

    public double getAccbalance() {
        return accbalance;
    }

    public void setAccbalance(double accbalance) {
        this.accbalance = accbalance;
    }

    public double getTurnover() {
        return turnover;
    }

    public void setTurnover(double turnover) {
        this.turnover = turnover;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Account{");
        sb.append("accNo=").append(accNo);
        sb.append(", accName='").append(accName).append('\'');
        sb.append(", accPassword='").append(accPassword).append('\'');
        sb.append(", accType=").append(accType);
        sb.append(", accbalance=").append(accbalance);
        sb.append(", turnover=").append(turnover);
        sb.append('}');
        return sb.toString();
    }

    public Account(int accNo, String accName, boolean accType) {
        this.accNo = accNo;
        this.accName = accName;
        this.accType = accType;
    }

    public void depoist(double turnover)
    {
        accbalance = accbalance+turnover;
        System.out.println(accName+"您好，您的账户已存入"+accbalance+"元"+"当前余额为："+accbalance+"元");
    }
    //取款
    public void withdrawl(String password,double turnover)
    {
        if(this.accPassword!=password)
        {
            System.out.println("抱歉，你输入的密码有误");
            return ;
        }
        if(accbalance-turnover>0)
        {
            System.out.println("您已取出"+turnover+"元"+"当前余额为"+(accbalance-turnover));
        }
        else
        {
            System.out.println("抱歉，你的余额已不足。");
        }

    }

}
